<!--
 * @Author: dawei 664690250@qq.com
 * @Date: 2023-03-28 17:19:37
 * @LastEditors: dawei 664690250@qq.com
 * @LastEditTime: 2023-04-06 18:39:45
 * @FilePath: /hn-talent-ump-vue/src/pages/schedule/ScheduleEditPage.vue
 * @Description: 请填写文件描述
 * 大佬别走，带带弟弟
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
-->
<template>
  <a-card :bordered="false">
    <div>
      <a-form @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="12" :sm="12">
            <a-form-item label="计划年份" :label-col="labelCol" :wrapper-col="wrapperCol">
              <a-input v-model="queryParam.planYear" placeholder="请输入计划年份" />
            </a-form-item>
          </a-col>
          <a-col :md="12" :sm="12">
              <a-form-item label="分解来源" :label-col="labelCol" :wrapper-col="wrapperCol">
                <a-input v-model="queryParam.source" placeholder="请输入分解来源" />
              </a-form-item>
            </a-col>
            <a-col :md="12" :sm="12">
              <a-form-item label="工作大类" :label-col="labelCol" :wrapper-col="wrapperCol">
                <a-input v-model="queryParam.category" placeholder="请输入工作大类" />
              </a-form-item>
            </a-col>
            <a-col :md="4" :sm="4" :offset="18">
              <a-form-item>
                <a-button type="primary" icon="search" @click="searchQuery()">查询</a-button>
                <a-button type="primary" icon="reload" style="margin-left: 8px" @click="searchReset()">重置</a-button>
              </a-form-item>
            </a-col>
        </a-row>
      </a-form>
    </div>
    <vxe-grid
        id="ScheduleEditList"
        ref="vxeTable"
        :row-config="{keyField:'id'}"
        v-bind="optionsBackup"
        v-on="listeners"
    >
      <template #action="{ row }">
        <a @click="handleEdit(row)">编辑</a>
        <a-divider type="vertical" />
        <a-dropdown>
          <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a @click="handleDetail(row)">详情</a>
            </a-menu-item>
            <a-menu-item>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(row.id)">
                <a>删除</a>
              </a-popconfirm>
            </a-menu-item>
            <a-menu-item>
              <a @click="handleEditPlanNode(row)">编辑计划节点</a>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </template>
    </vxe-grid>
    <ScheduleModal @ok="modalFormOk" ref="modalForm"></ScheduleModal>
    <ScheduleNodeModal @ok="modalTableOk" ref="modalTable"></ScheduleNodeModal>
  </a-card>
</template>

<script>
import { VxeTableMixin } from '@/mixins/VxeTableMixin'
import ScheduleModal from './modules/ScheduleModal'
import ScheduleNodeModal from './modules/ScheduleNodeModal'
export default {
  name: 'ScheduleEditPage',
  mixins: [VxeTableMixin],
  components: {
    ScheduleModal,
    ScheduleNodeModal
  },
  data() {
    return {
      columns: [
        { title: '序号', type: 'seq', width: 50, fixed: 'left' },
        // { title: '计划年份', field: 'planYear', width: 150 },
        { title: '分解来源', field: 'source', width: 150 },
        { title: '工作大类', field: 'category', width: 150 },
        { title: '重点工作', field: 'priority', width: 500 },
        { title: '主责部门名称', field: 'responsibleDpt', width: 500 },
        { title: '分管领导', field: 'leaderName', width: 200 },
        { title: '完成标志', field: 'completionMark', width: 300 },
        { title: '起始时间', field: 'startTime', width: 300 },
        { title: '截止时间', field: 'endTime', width: 300 },
        { title: '操作', field: 'action', width: 200, fixed: 'right', slots: { default: 'action' }}
      ],
      url: {
        list: '/plan/schedule/v1/page',
        delete: '/plan/schedule/v1/remove/',
        deleteBatch: '/plan/schedule/v1/remove/'
      }
    }
  },
  computed: {
    optionsBackup() {
      return {
        ...this.options,
        data: [...this.dataSource.map(item => {
          return {
            ...item,
            responsibleDpt: item.mgrDept.map(item => item.deptName),
            responsibleDepts: item.mgrDept.map(item => item.deptCode).join(','),
            startEndTime: [item.startTime, item.endTime],
            deptIds: item.mgrDept.map(item => item.deptId)
          }
        })]
      }
    }
  },
  mounted() {

  },
  methods: {
    handleEditPlanNode(record) {
      this.$refs.modalTable.edit({ ...record })
      this.$refs.modalTable.title = '编辑计划节点'
    },
    modalTableOk() {

    }
  }
}
</script>
